<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="menu.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
tr{
 cursor: pointer;
}
</style>
<script>
var id = null;

$(function(){
	
	$("#divTabelaOsGeral").load("ajax/tabelaOsGeral.jsp");
	
	var height = $(window).height() - 66;
	var width = $(window).width();
	
	$("fieldset").css("height", height);
	
	$("#dialogDetalhe").dialog({
		autoOpen : false,
		height : 'auto',
		width : 'auto',
		modal : true,
		resizable : false,
		close:function(){
			$("#imprimir_msn").html("");
		}
	});
	
	$("#imprimir_OS").button().click(function(){
		$.ajax({
			url : "relatorio",
			data : {id:id, tipoRelatorio:"imprimirOS"},
			beforeSend : function() {
				$("#imprimir_msn").html("Carregando...");
			},
			success : function(html) {
				if(html != ""){
					$("#imprimir_msn").html(html);
				}else{
					$("#imprimir_msn").html("");
					window.open("relatorios/relatorio.pdf");
				}
			},
			error:function(){
				$("#imprimir_msn").html("Erro de conexão!");
			}
		});
	});
	
});

function detalhe(id3){
	id = id3;
	
	$.ajax({
		url:"detalheOsServlet",
		dataType: "xml",
		data:{id:id},
		beforeSend:function(){
			document.documentElement.style.cursor = 'progress';
			$("#dialogCarregando").dialog("open");
		},
		success:function(xml){
			$(xml).find('os').each(function () {
				$("#numeroOS").html($(this).find('idos').text());
				$("#secretarioResponsavel").html($(this).find('secRes').text());
				$("#situacao").html($(this).find('situacao').text());
				$("#designerResponsavel").html($(this).find('desRes').text());
				$("#dataEntrada").html($(this).find('dataEntrada').text());
				$("#dataAprovacao").html($(this).find('dataAprovacao').text());
				$("#dataEntrega").html($(this).find('dataEntrega').text());
				$("#cliente").html($(this).find('cliente').text());
				$("#endereco").html($(this).find('endereco').text());
				$("#bairro").html($(this).find('bairro').text());
				$("#cidade").html($(this).find('cidade').text());
				$("#cpfCnpj").html($(this).find('cpfCnpj').text());
				$("#telefone").html($(this).find('telefone').text());
				$("#celular").html($(this).find('celular').text());
				$("#dataCadastro").html($(this).find('dataCadastro').text());
				$("#descricaoOS").html($(this).find('descricao').text());
			});
			$("#dialogDetalhe").dialog("open");
			document.documentElement.style.cursor = 'default';
			$("#dialogCarregando").dialog("close");
		},
		error:function(){
			document.documentElement.style.cursor = 'default';
			$("#dialogCarregando").dialog("close");
		}
	});
}
</script>
</head>
<body>
	<fieldset class="ui-corner-all"
		style="margin-top: 10px; margin-bottom: -10px; padding-left: 0px; padding-right: 0px;">
		<legend class="ui-corner-all" style="font-size: 14px; margin-left: 8px;">Registros das Ordens de Serviço</legend>
		<p>
	<div id="divTabelaOsGeral">
		<div style="font-weight: bold;">Carregando dados...</div> 
	</div>
</fieldset>
<!-- Dialogs -->

<div id="dialogDetalhe" title="" style="font-size: 15px; display: none;">
<%@ include file="detalheOS.jsp" %>
</div>
</body>
</html>